@{ViewBag.Title = " Persona "; Layout = "../Shared/_LayoutJtable.cshtml";}

<div class="filtering"><form>    
    <label>Apellido Paterno: <input type="text" name="apellidoPaterno" id="apellidoPaterno" /></label>
    <label>Apellido Materno: <input type="text" name="apellidoMaterno" id="apellidoMaterno" /></label>
    <label>Nombre: <input type="text" name="nombres" id="nombres" /></label>
<button type="submit" id="LoadRecordsButton" class="button medium orange" >Buscar Coincidencias</button>
    @Html.ActionLink("Crear Nueva Persona", "DataForm", null, new { @class = "button medium green" })
</form></div>
<div id="MyTableContainer"></div>
<script type="text/javascript">
     $(document).ready(function () {
     $('#MyTableContainer').jtable({
         title: 'Persona',
         paging: true,
         pageSize: 40,
         sorting: true,
         defaultSorting: 'Id ASC',
         actions: {
             listAction: '@Url.Action("JSONDataPagerSearch")',
             deleteAction: '@Url.Action("JSONDelete")'
             
         },
         fields:
         {
          Id: {
                 key: true,
                 create: false,
                 edit: false,
                 list: false
              }
              ,
              Guid:
              {
                type: 'hidden'
              }
             ,
             Codigo: {
                 title:'Codigo',
                 create: true,
                 edit: true,
                 list: true,
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             CI: {
                 title:'CI',
                 create: true,
                 edit: true,
                 list: true,
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             CIMilitar: {
                 title:'CIMilitar',
                 create: true,
                 edit: true,
                 list: true,
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             Nombres: {
                 title:'Nombres',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             ApellidoPaterno: {
                 title:'ApellidoPaterno',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             ApellidoMaterno: {
                 title:'ApellidoMaterno',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             Genero: {
                 title:'Genero',
                 create: true,
                 edit: true,
                 list: true,
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             FechaNacimiento: {
                 title:'FechaNacimiento',
                 create: true,
                 edit: true,
                 list: true,
                 type: 'date',
                 displayFormat: 'mm-dd-yy',
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             LugarNacimiento: {
                 title:'LugarNacimiento',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             } 
             ,
             Email: {
                 title:'Email',
                 create: true,
                 edit: true,
                 list: false,
                 sorting: false
             }
             ,
             FechaEgreso: {
                 title:'FechaEgreso',
                 create: true,
                 edit: true,
                 list: true,
                 type: 'date',
                 displayFormat: 'dd/mm/yy',
                 sorting: false
             }
             ,
             NumAntiguedadEgreso: {
                 title:'Antig.Egreso',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             EsPersonaCivil: {
                 title:'Civil',
                 create: true,
                 edit: true,
                 list: true,
                 type: 'checkbox',
                 values:{'false':'NO','true':'SI'},
                 sorting: false
             },
             Dataform:
             {
                 title: 'Actualizar',
                 width: '10px',
                 sorting: false,
                 edit: false,
                 create: false,
                 listClass: 'child-opener-image-column',
                 display: function (tempData) {
                     var $img = $('<img class="child-opener-image" with="20" height="20" src="../Content/images/comment.png" title="Actualizar Datos" />');
                     $img.click(function () {
                         //window.open('../Reporte/FilePersonal?PersonaId=' + tempData.record.Id);
                         location.href = '../Persona/IrADataForm?PersonaId=' + tempData.record.Id;
                     });

                     return $img;
                 }
             },
             EnviarEmail:
             {
                title: 'Enviar',
                width: '50px',
                sorting: false,
                edit: false,
                create: false,
                listClass: 'child-opener-image-column',
                display: function (tempData) {
                    var $img = $('<img class="child-opener-image" with="20" height="20" src="../Content/images/comment.png" title="Email" />');
                    $img.click(function () {
                        //window.open('../Persona/EnviarEmail?guid=' + tempData.record.Guid);
                        location.href = '../Persona/EnviarEmail?guid=' + tempData.record.Guid;
                    });

                    return $img;
                }
             },
             Foto:
             {
                 title: 'Foto',
                 width: '50px',
                 sorting: false,
                 edit: false,
                 create: false,
                 listClass: 'child-opener-image-column',
                 display: function (tempData) {
                     var $img = $('<img class="child-opener-image" with="20" height="20" src="../Content/images/comment.png" title="Actualizar Foto" />');
                     $img.click(function () {
                         //window.open('../Media/Cargar?guid=' + tempData.record.Guid);
                         location.href = '../Media/Cargar?guid=' + tempData.record.Guid+'&titulo='+tempData.record.ApellidoPaterno+' '+tempData.record.ApellidoMaterno+' '+tempData.record.Nombre1;
                     });

                     return $img;
                 }
             }
             @*,
             PersonaConyugeId_FK:{
                 title : 'Conyuge',
                 create : true,
                 edit : true,
                 list : true,
                 options : '@Url.Action("../Persona/JSONGetElementsForDropDownList")'
             }*@
},
formCreated: function (event, data) {data.form.validationEngine();},
formSubmitting: function (event, data) {return data.form.validationEngine('validate');},
formClosed: function (event, data) { data.form.validationEngine('hide'); data.form.validationEngine('detach'); }
});
$('#LoadRecordsButton').click(function (e) { e.preventDefault(); $('#MyTableContainer').jtable('load', { nombres: $('#nombres').val(), apellidoPaterno: $('#apellidoPaterno').val(), apellidoMaterno: $('#apellidoMaterno').val() }); });
$('#LoadRecordsButton').click();
});
</script>

